///*
// * To change this template, choose Tools | Templates
// * and open the template in the editor.
// */
//package linkeddata.arida.ufc.br.rascunhos;
//
//import java.io.IOException;
//import java.util.Arrays;
//import java.util.LinkedHashMap;
//import java.util.LinkedHashSet;
//import java.util.Map;
//import java.util.Set;
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import linkeddata.arida.ufc.br.manager.impl.BuildsSparqlQuery;
//import linkeddata.arida.ufc.br.util.OWLUtils;
//import org.semanticweb.owlapi.model.OWLOntologyCreationException;
//
///**
// *
// * @author jeovane
// */
//public class ObtainsValuesMenuServlet extends HttpServlet {
//
//    @Override
//    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
//        String[] menu = request.getParameterValues("menu[]");
//        String[] subMenu = request.getParameterValues("subMenu[]");
//        String[] optional = request.getParameterValues("optional[]");
//        String domainOntology = request.getParameter("domainOntology");
//        String activeUnion = "";
//        String query = "";
//
//        OWLUtils utils = new OWLUtils(domainOntology);
//        utils.ontologyLoaded();
//        BuildsSparqlQuery bsq = new BuildsSparqlQuery();
//
//        Map<String, Set<String>> mapTeste = new LinkedHashMap<String, Set<String>>();
//        Set<String> setSubMenu = new LinkedHashSet<String>();
//        Set<String> setFilter = new LinkedHashSet<String>();
//        Set<String> setOpt = new LinkedHashSet<String>();
//
//        for (int i = 0; i < subMenu.length; i++) {
//            String[] subMenus = subMenu[i].split(",");
//            setSubMenu.addAll(Arrays.asList(subMenus));
//        }
//
//        for (int i = 0; i < menu.length; i++) {
//            String[] menus = menu[i].split(",");
//            for (int j = 0; j < menus.length; j++) {
//                mapTeste.put(menus[j], setSubMenu);
//            }
//        }
//        
//        for (int i = 0; i < optional.length; i++) {
//            String[] optionals = optional[i].split(",");
//            setOpt.addAll(Arrays.asList(optionals));
//        }
//
//        try {
//            bsq.buildsSelect(mapTeste, activeUnion, utils.getOntology(), utils.getPm(), utils.getReasoner());
//            query = bsq.buildsWhere(mapTeste, setOpt, setFilter, utils.getOntology(), utils.getPm(), utils.getReasoner());
//        } catch (OWLOntologyCreationException ex) {
//            System.out.println("Erro: " + ex.getMessage());
//        }
//
//        response.setContentType("text/plain");
//        response.setCharacterEncoding("UTF-8");
//        response.getWriter().write(query);
//    }
//}